﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Runtime.InteropServices;

namespace Kiosk
{
    /// <summary>
    /// Interaction logic for AdditionalComments.xaml
    /// </summary>
    public partial class AdditionalComments : Window
    {
        OnScreenKeyboard theKeyboard = new OnScreenKeyboard();
        public AdditionalComments()
        {
            InitializeComponent();

            gridRight.Children.Add(theKeyboard);
            Grid.SetRow(theKeyboard, 1);
            Grid.SetColumn(theKeyboard, 0);
            theKeyboard.VerticalAlignment = VerticalAlignment.Bottom;
        }//end constructor AdditionalComments

        /// <summary>
        /// This method returns the user to the previous page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            sGlobals.contactMentor.Show();
            this.Close();
        }//end method btnBack_Click

        /// <summary>
        /// This method logs the user out of the kiosk. It is called when the user presses the logout button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogout_Click(object sender, RoutedEventArgs e)
        {
         //   this.Close();
            sGlobals.logout();
        }

        /// <summary>
        /// This method clear's the additional comments box and returns the user to the Contact Mentor page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            //txtBoxAdditionalComments.Clear();
            sGlobals.contactMentor.Show();
            this.Close();
        }//end method btnLogout_Click

        /// <summary>
        /// This method brings up window to prompt user for password.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            PasswordPrompt passPrompt = new PasswordPrompt(txtBoxAdditionalComments.Text);
            passPrompt.previousWindow = this;
            passPrompt.ShowDialog();
        }//end method btnSendEmail_Click

        private void focusHandler(object sender, RoutedEventArgs e)
        {
            if (sender is TextBox) //show keyboard and bind
            {
                theKeyboard.bindToControl((TextBox)sender);
                theKeyboard.show();
            }
            else if (sender is OnScreenKeyboard) // special do nothing case...focus is getting bounced around between the keyboard and bound control
            {

            }
            else //hide keyboard (clicked button or window or something)
            {
                theKeyboard.clearControlBinding();
                theKeyboard.hide();
            }
        }//end class focusHandler

        private void btnPathways_Click(object sender, RoutedEventArgs e)
        {
            sGlobals.pathways.Show();
            this.Hide();
        }

        private void btnFocusedAreas_Click(object sender, RoutedEventArgs e)
        {
            sGlobals.focusedAreasOfStudy.Show();
            this.Hide();
        }

        private void windowLeftMouseButtonUp(object sender, MouseButtonEventArgs e)
        {
            theKeyboard.clearControlBinding();
            theKeyboard.hide();
            btnSendEmail.Focus();
        }//end class windowLeftMouseButtonUp
    }//end partial class AdditionalComments : Window
}//end namespace Kiosk
